home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / XCMDs / ScreenWidth XFCN 1.0.1 / ScreenWidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-15  |  1.5 KB  |  68 lines  |  [TEXT/CWIE]

  1. /* ----------------------------------------------------------------------
  2.  
  3.     ScreenWidth XFCN
  4.     version 1.0.1
  5.     
  6.     Written by: Paul Celestin
  7.     
  8.     Copyright © 1993-1995 Celestin Company, Inc.
  9.     
  10.     This XFCN returns the width of the main screen in pixels.
  11.     
  12.     No parameters required!
  13.     
  14.     930925 - 1.0.0 - initial release
  15.     951215 - 1.0.1 - updated for CW7
  16.  
  17. ---------------------------------------------------------------------- */
  18.  
  19. #include <A4Stuff.h>
  20. #include <HyperXCmd.h>
  21.  
  22. #define PARAMETER_NUMS        0
  23. #define PARAMETER_TEXT        "\pNo parameters required!"
  24.  
  25.  
  26. /* ----------------------------------------------------------------------
  27. prototypes
  28. ---------------------------------------------------------------------- */
  29. void DoIt(XCmdPtr paramPtr);
  30. char LookUp[256];
  31.  
  32.  
  33. /* ----------------------------------------------------------------------
  34. main
  35. ---------------------------------------------------------------------- */
  36. pascal void main(XCmdPtr paramPtr)
  37. {
  38.     long oldA4 = SetCurrentA4();
  39.     if (paramPtr->paramCount != PARAMETER_NUMS)
  40.     {
  41.         paramPtr->returnValue =
  42.             PasToZero(paramPtr,PARAMETER_TEXT);
  43.     }
  44.     else
  45.     {
  46.         DoIt( paramPtr );
  47.     }
  48.     SetA4(oldA4);
  49. }
  50.  
  51. /* ----------------------------------------------------------------------
  52. DoIt
  53. ---------------------------------------------------------------------- */
  54. void DoIt(XCmdPtr paramPtr)
  55. {
  56.     long        width;
  57.     Str255        myString;
  58.     GDHandle    curDev;
  59.     Rect        bounds;
  60.  
  61.     curDev = GetMainDevice();
  62.     bounds = (**curDev).gdRect;
  63.     width = bounds.right - bounds.left;
  64.  
  65.     NumToStr(paramPtr,width,myString);
  66.     paramPtr->returnValue = PasToZero(paramPtr,myString);
  67. }
  68.